package com.zushiye.order.mapper;

import com.zushiye.order.model.CartItemBean;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CartMapper {

    @Insert("insert into cart(user_id, id_, name, stock, price, des, icon_id) " +
            "values(#{user_id}, #{id_}, #{name}, #{stock}, #{price}, #{des}, #{icon_id})")
    int insert(CartItemBean itemBean);

    @Delete("delete from cart where id = #{id}")
    int delete(String id);

    /*
    //DELETE FROM employees WHERE employee_id IN (1, 2, 3, 4, 5);
    @Delete("DELETE FROM cart WHERE id IN ( #{ids} )")
    int batchDelete(String ids);
    */
    //@Delete("DELETE FROM cart WHERE id IN ( #{ids} )")
    int batchDelete(List<Integer> idList);

    @Select("select * from cart where user_id = #{user_id}")
    List<CartItemBean> queryAll(String user_id);

}
